<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fnx" uri="http://java.sun.com/jsp/jstl/functionsx" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/views/head.jsp"/>
    <script type="text/javascript">
        $(function () {
            $("#validForm").validate({
                submitHandler: function (form) {
                    $("#validForm input[name|='dy']").each(function () {
                        var name = $(this).attr("name");
                        $(this).attr("name", name.substring(3, name.lastIndexOf("-")));
                    });
                    form.submit();
                }
            });

          $("input[name='name']").focus();

        });

        function confirmDelete() {
          alert(1);
            return confirm("<s:message code='confirmDelete'/>");
        }

        function optMulti(form, action, msg) {
            if (Cms.checkeds("ids") == 0) {
                alert("<s:message code='pleaseSelectRecord'/>");
                return false;
            }
            if (msg && !confirm(msg)) {
                return false;
            }
            form.action = action;
            form.submit();
            return true;
        }

        function liveSave(form, action, msg) {
            if (msg && !confirm(msg)) {
                return false;
            }
            form.action = action;
            form.submit();
            return true;
        }
    </script>
</head>
<body class="skin-blue content-body">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
    <h1>市州服务配置 - <s:message code="${oprt=='edit' ? 'edit' : 'create'}"/></h1>
</div>
<c:set var="numberExist"><s:message code="vote.number.exist"/></c:set>
<div class="content">
    <div class="box box-primary">
        <form class="form-horizontal" id="validForm" action="${oprt=='edit' ? 'update' : 'save'}.do" method="post">
            <tags:search_params/>
            <f:hidden name="id" value="${bean.id}"/>
            <f:hidden name="position" value="${position}"/>
            <input type="hidden" id="redirectLive" name="redirect" value="edit"/>
            <div class="box-header with-border">
                <div class="btn-toolbar">
                    <div class="btn-group">
                        <shiro:hasPermission name="ext:cityconfig:create">
                            <button class="btn btn-default" type="button"
                                    onclick="location.href='create.do?stat=${stat}';"<c:if
                                    test="${oprt=='create'}"> disabled="disabled"</c:if>><s:message
                                    code="create"/></button>
                        </shiro:hasPermission>
                    </div>
                    <div class="btn-group">
                        <shiro:hasPermission name="ext:cityconfig:delete">
                            <button class="btn btn-default" type="button"
                                    onclick="if(confirmDelete()){location.href='delete.do?ids=${bean.id}';}"
                                    <c:if test="${oprt=='create'}"> disabled="disabled"</c:if>><s:message
                                    code="delete"/></button>
                        </shiro:hasPermission>
                    </div>

                    <div class="btn-group">
                        <button class="btn btn-default" type="button"
                                onclick="location.href='list.do';"><s:message
                                code="return"/></button>
                    </div>
                </div>
            </div>
            <div class="box-body">
            <div class="row">
                <div class="col-sm-8">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">一级市州:</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="parentId">
                                <f:option value="">--请选择--</f:option>
                                <c:forEach var="onebean" varStatus="status" items="${oneLevelList}">
                                <f:option value="${onebean.id}" selected="${bean.parentId}" >${onebean.cityName}</f:option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-8">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><em class="required">*</em>市州名称:</label>
                        <div class="col-sm-10">
                            <f:text name="cityName" value="${bean.cityName}"
                                    class="form-control required" maxlength="250"/>
                        </div>
                    </div>
                </div>
            </div>
                <div class="row">
                    <div class="row">
                        <div class="col-sm-8">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">市州图标:</label>
                                <div class="col-sm-10">
                                    <script>
                                      function fn_smallImage(src) {
                                        Cms.scaleImg("img_smallImage", 200, 100, src);
                                      };
                                    </script>
                                    <div style="display:table;width:100%;">
                                        <div style="display:table-cell;vertical-align:middle;">
                                            <div class="input-group">
                                                <span class="input-group-addon">地址</span>
                                                <input type="text" id="smallImage" name="cityImage"
                                                       value="${bean.cityImage}"
                                                       onchange="fn_smallImage(this.value);" class="form-control">
                                            </div>
                                            <div class="form-inline" style="margin-top:3px;">
                                                <button class="btn btn-default" type="button" id="smallImageButton">选择
                                                </button>
                                                <object id="SWFUpload_0" type="application/x-shockwave-flash"
                                                        data="/static/vendor/swfupload/swfupload.swf?preventswfcaching=1502702265304"
                                                        width="54" height="34" class="swfupload">
                                                    <param name="wmode" value="transparent">
                                                    <param name="movie"
                                                           value="/static/vendor/swfupload/swfupload.swf?preventswfcaching=1502702265304">
                                                    <param name="quality" value="high">
                                                    <param name="allowScriptAccess" value="always">
                                                    <param name="flashvars"
                                                           value="movieName=SWFUpload_0&amp;uploadURL=%2Fcmscp%2Fcore%2Fupload_image.do%3Bjsessionid%3DB7EED2164EABD024D9BFE3361803971D%3F_site%3D&amp;useQueryString=false&amp;requeueOnError=false&amp;httpSuccess=&amp;assumeSuccessTimeout=0&amp;params=&amp;filePostName=file&amp;fileTypes=*.*&amp;fileTypesDescription=Images&amp;fileSizeLimit=0&amp;fileUploadLimit=0&amp;fileQueueLimit=0&amp;debugEnabled=false&amp;buttonImageURL=&amp;buttonWidth=54&amp;buttonHeight=34&amp;buttonText=&amp;buttonTextTopPadding=0&amp;buttonTextLeftPadding=0&amp;buttonTextStyle=color%3A%20%23000000%3B%20font-size%3A%2016pt%3B&amp;buttonAction=-100&amp;buttonDisabled=false&amp;buttonCursor=-2">
                                                </object>
                                                <button class="btn btn-default" type="button">上传</button>
                                                <div style="display: none">
                                                    <button class="btn btn-default" type="button" id="smallImageSwfCancel"
                                                            onclick="smallImageSwfUpload.cancelQueue();" disabled="">取消
                                                    </button>
                                                </div>

                                            </div>

                                            <input type="hidden" id="t_smallImage" value="false">
                                            <input type="hidden" id="tw_smallImage" value="116">
                                            <input type="hidden" id="th_smallImage" value="77">
                                        </div>
                                        <div style="width:200px;display:table-cell;vertical-align:middle;text-align:center;">
                                            <img id="img_smallImage" <c:if test="${empty bean.cityImage}">style="display:none;"</c:if>  src="${bean.cityImage}">
                                        </div>
                                    </div>
                                    <div id="smallImageSwfProgress"></div>
                                    <script>
                                      var smallImageSwfUpload = Cms.swfUploadImage("smallImage", {
                                        jsessionid: "B7EED2164EABD024D9BFE3361803971D",
                                        file_size_limit: "0",
                                        file_types: "*.*"
                                      });
                                      $(function () {
                                        Cms.f7.uploads("smallImage", "smallImage", {
                                          settings: {"title": "选择附件"},
                                          callbacks: {
                                            "ok": function (src) {
                                              fn_smallImage(src);
                                            }
                                          }
                                        });
                                      });
                                    </script>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            <div class="row">
                <div class="col-sm-8">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">链接url:</label>
                        <div class="col-sm-10">
                            <f:text name="url" value="${bean.url}"
                                    class="form-control" maxlength="250"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-8">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">是否同步数据:</label>
                        <div class="col-sm-10">
                        <select class="form-control" name="syncData">
                            <f:option value="true" selected="${bean.syncData}"><s:message code="yes"/></f:option>
                            <f:option value="false" selected="${bean.syncData}"><s:message code="no"/></f:option>
                        </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-8">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">是否H5:</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="h5">
                                <f:option value="true" selected="${bean.h5}"><s:message code="yes"/></f:option>
                                <f:option value="false" selected="${bean.h5}"><s:message code="no"/></f:option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-8">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">机构Id:</label>
                        <div class="col-sm-10">
                            <f:text name="institutionId" value="${bean.institutionId}"
                                    class="form-control digits" maxlength="9"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-8">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">机构名称:</label>
                        <div class="col-sm-10">
                            <f:text name="institutionName" value="${bean.institutionName}"
                                    class="form-control" maxlength="250"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-8">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">机构url:</label>
                        <div class="col-sm-10">
                            <f:text name="institutionUrl" value="${bean.institutionUrl}"
                                    class="form-control" maxlength="250"/>
                        </div>
                    </div>
                </div>
            </div>
                <div class="row">
                    <div class="col-sm-8">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">机构接口域名:</label>
                            <div class="col-sm-10">
                                <f:text name="domainName" value="${bean.domainName}"
                                        class="form-control" maxlength="250"/>
                            </div>
                        </div>
                    </div>
            <div class="row">
                <div class="col-sm-8">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><em class="required">*</em>顺序:</label>
                        <div class="col-sm-10">
                            <f:text name="seq" value="${bean.seq}"
                                    class="form-control required digits" maxlength="9"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-8">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><em class="required">*</em>是否发布: </label>
                        <div class="col-sm-10">
                            <select class="form-control required" name="publish">
                                <f:option value="1" selected="${bean.publish}" >是</f:option>
                                <f:option value="2" selected="${bean.publish}" >否</f:option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>

            </div>

            <%-----------------------------------------------------------[  按钮 保存 如下:  ]----------------------------------------------------------------------------------%>
            <div class="box-footer">
                <shiro:hasPermission name="ext:cityconfig:save">
                <button class="btn btn-primary" type="submit" onclick="$('#redirectLive').val('edit');"><s:message
                        code="save"/></button>
                <button class="btn btn-default" type="submit" onclick="$('#redirectLive').val('list');"><s:message
                        code="saveAndReturn"/></button>
                <c:if test="${oprt=='create'}">
                    <button class="btn btn-default" type="submit" onclick="$('#redirectLive').val('create');"><s:message
                            code="saveAndCreate"/></button>
                </c:if>
                </shiro:hasPermission>

            </div>
        </form>
    </div>
</div>
</div>
</body>
</html>